#ifndef TOMATOCLOCKWIDGET_H
#define TOMATOCLOCKWIDGET_H

#include <QWidget>
#include <QTimer>
#include <QTime>
#include <QPropertyAnimation>
#include <QGraphicsOpacityEffect>
#include "dbBase.h"
#include <QSystemTrayIcon>
class QLabel;
class QPushButton;
class QProgressBar;

class TomatoClockWidget : public QWidget
{
    Q_OBJECT
        Q_PROPERTY(int progressValue READ getProgressValue WRITE setProgressValue)

public:
    explicit TomatoClockWidget(QWidget* parent = nullptr);

public slots:
    void startTimer();
    void pauseTimer();
    void resetTimer();
    void completeTomato();
    void CustomTimer();

private slots:
    void updateTimer();

private:
    void setupUI();
    void setupAnimations();
    int getProgressValue() const { return m_progressValue; }
    void setProgressValue(int value);

    // UI组件
    QLabel* m_timeLabel;
    QLabel* m_statusLabel;
    QLabel* m_tomatoCountLabel;
    QLabel* m_dailyGoalLabel;
    QProgressBar* m_progressBar;
    QPushButton* m_startButton;
    QPushButton* m_pauseButton;
    QPushButton* m_resetButton;
    QPushButton* m_completeButton;
    QPushButton* m_CustomTimerButton;
    QPushButton* m_CustomNewDayButton;
    QSystemTrayIcon* m_trayIcon;
    // 计时器相关
    QTimer* m_timer;
    QTime m_remainingTime;
    QTime CustomWorkTimer;
    QTime CustomRestTimer;
    bool m_isWorking;
    int m_completedTomatoes;
    int m_progressValue;
    SqlLite* m_db;

    bool is_contiune;

    // 动画效果
    QPropertyAnimation* m_progressAnimation;
    QGraphicsOpacityEffect* m_pulseEffect;
    QPropertyAnimation* m_pulseAnimation;
};

#endif // TOMATOCLOCKWIDGET_H